package cn.online.zhuanshenben.vo;

import java.io.Serializable;
import java.util.*;

/**
 * @author oldliu
 * @since 1.0
 */
//分页准备
public class Page<T> implements Serializable {
    private int code = 0;//是否成功，0表示成功
    private String msg = "成功";//操作信息
    private long count;//总数
    private int page;//页号
    private int limit = 10;//页大小
    private List<T> data = new ArrayList<>();//本页数据

    public Page() {

    }

    public Page(long count, List<T> data) {
        this.count = count;
        this.data = data;
    }

    public Page(long count, int page, int limit, List<T> data) {
        this.count = count;
        this.page = page;
        this.limit = limit;
        this.data = data;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public int getPage() {
        return page;
    }

    public void setPage(int page) {
        this.page = page;
    }

    public int getLimit() {
        return limit;
    }

    public void setLimit(int limit) {
        this.limit = limit;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public long getCount() {
        return count;
    }

    public void setCount(long count) {
        this.count = count;
    }

    public List<T> getData() {
        return data;
    }

    public void setData(List<T> data) {
        this.data = data;
    }

    public long getPages() {
        return this.count / this.limit + (this.count % this.limit == 0 ? 0 : 1);
    }
}
